<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	
<%@page import="com.lovo.bbs.vo.*,com.lovo.bbs.bo.*,java.util.*"%>
	
<%
    // 取得所有板块列表
	ArrayList<BoardVo> boardList = (ArrayList<BoardVo>) application
				.getAttribute("boardList");
	// 更新板块列表
	if (boardList == null) {
			boardList =new  BoardBo().getAllBoard();
			application.setAttribute("boardList", boardList);
	}
	
	String queryPages = (String)request.getAttribute("queryPage");
	if(queryPages==null){
	  queryPages="1";
	}
	int queryPage=Integer.parseInt(queryPages);
	
	int boardCount = boardList.size();
	int pageNum = (boardCount % 20 == 0) ? (boardCount / 20) : (boardCount / 20 + 1);
	Iterator it;
	
%>
<html>
	<head>
		<link href="../../../css/admin.css" rel="stylesheet" type="text/css" />
		<script language="javaScript">
		function preInsert(){
		    document.frmMain.opType.value="1";
		    document.frmMain.action="boardManageUpdatePage.jsp";
		    document.frmMain.submit();
		}
		function preModify(boardid,boardname){
		    document.frmMain.boardid.value=boardid;	   
		    document.frmMain.boardname.value=boardname;	     

		    document.frmMain.opType.value="2";
		    document.frmMain.action="boardManageUpdatePage.jsp?";
		    document.frmMain.submit();		   
		}
		function preDelete(boardid,boardname){
		    document.frmMain.boardid.value=boardid;	   
		    document.frmMain.boardname.value=boardname;	     

		    document.frmMain.opType.value="3";
		    document.frmMain.action="boardManageUpdatePage.jsp";
		    document.frmMain.submit();	
		}
		</script>
	</head>
	<body>
	<form name="frmMain" method="post">
		<table class="navigation" style="width:98%" align="center">
			<tr>
				<td>
					当前位置: 版块管理
				</td>
			</tr>
		</table>
		<table border="0" cellspacing="0" cellpadding="0" style="width:98%" align="center">
			<tr>
				<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="4">
						<tr>
							<td id="content_bar">
								<a class="content_total">版块总数: <%=boardCount%> ,第<%=queryPage%>页	总<%=pageNum%>页 </a>
								<%	for (int i = 1; i <= pageNum; i++) {
										if (i == queryPage) {
								%>
								<a class="content_pasges_c"><%=i%></a>
								<%} else {%>
								<a class="content_pasges_a"	href="BoardManageQuery?queryPage=<%=i%>"><%=i%></a>
								<% }}%>
								<input name="add" type="button" style="float:right"	class="button" value=" 增加新版块 " onclick="preInsert()">
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table border="0" cellspacing="1" cellpadding="4" class="tableborder" style="background-color:#CCFFFF; border:#99FFCC 0px solid">
						<tr class="header">
							<td width="30%">
									版块名称
							</td>
							<td width="40%">
									&nbsp;
							</td>
							<td width="10%">
								&nbsp;
							</td>
							<td width="15%">
									操作
							</td>
						</tr>
						<%	if (boardList == null) {
								boardList = new ArrayList();
								System.out.println("对象为空");
							}
							it = boardList.iterator();
							if (it != null) {
								while (it.hasNext()) {
									BoardVo boardData = (BoardVo) (it.next());
						%>
						<tr class="row">
							<td>
								<%=boardData.getBoardName()%>
							</td>
							<td>
								&nbsp;
							</td>
							<td>
								&nbsp;
							</td>
							<td>
								<input type="button" value=" 修改 " class="button" onclick="preModify('<%=boardData.getBoardID()%>','<%=boardData.getBoardName()%>')">
								<input type="button" value=" 删除 " class="button" style="color:#ff0000;" onclick="preDelete('<%=boardData.getBoardID()%>','<%=boardData.getBoardName()%>')">
							</td>
						</tr>
						<%} }%>
					</table>
				</td>
			</tr>
		</table>
		<br>
		<input type="hidden" name="boardid" value="">
		<input type="hidden" name="boardname" value="">

		<input type="hidden" name="opType" value="">
		<input type="hidden" name="queryPage" value="<%=queryPage%>">
		
	</form>
	</body>
</html>
